#交叉编译环境
set(CMAKE_SYSTEM_NAME Linux)     #mandatory [Windows] or[Generic](embedded system without os),if CMAKE_SYSTEM_NAME is preset, then CMAKE_CROSSCOMPILING is automatically set to TRUE
set(CMAKE_SYSTEM_PROCESSOR aarch64) #optional, 在每个交叉编译器需要特定flag设定时，可以通过加载CMAKE_SYSTEM_NAME-compiler-CMAKE_SYSTEM_PROCESSOR.cmake file

#gnu c/c+编译器flags置空
set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Debug CFLAGS")
set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
set(CMAKE_C_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release CFLAGS")
set(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release CXXFLAGS")

set(TARGET_SYSROOT "/home/wzl/workspace/firefly/rv1126_rv1109_linux_release_20211022/buildroot/output/firefly_rv1126_rv1109/host/arm-buildroot-linux-gnueabihf/sysroot")
set(CMAKE_C_FLAGS "${CFLAGS} --sysroot=${TARGET_SYSROOT}" CACHE STRING "OE CFLAGS")
set(CMAKE_CXX_FLAGS "${CXXFLAGS} --sysroot=${TARGET_SYSROOT}" CACHE STRING "OE CXXFLAGS")
set(CMAKE_EXE_LINKER_FLAGS "${LDFLAGS}" CACHE STRING "OE LDFLAGS for executables")

set(CMAKE_INSTALL_SO_NO_EXE 0)

set(NATIVE_SYSROOT "/home/wzl/workspace/firefly/rv1126_rv1109_linux_release_20211022/buildroot/output/firefly_rv1126_rv1109/host")
set(CMAKE_PROGRAM_PATH "${NATIVE_SYSROOT}/usr/bin")
set(CMAKE_SYSROOT "${TARGET_SYSROOT}")
set(CMAKE_FIND_ROOT_PATH ${TARGET_SYSROOT} ${NATIVE_SYSROOT})
list(APPEND CMAKE_FIND_ROOT_PATH "${NATIVE_SYSROOT}/opt/ros/kinetic") #ros

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# This toolchain file can be used both inside and outside Buildroot.
#设置编译器,链接器等编译工具链
set(CMAKE_C_COMPILER "${NATIVE_SYSROOT}/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "${NATIVE_SYSROOT}/bin/arm-linux-gnueabihf-g++")
set(CMAKE_ASM_COMPILER "${NATIVE_SYSROOT}/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_AR "${NATIVE_SYSROOT}/bin/arm-linux-gnueabihf-ar" CACHE FILEPATH "Archiver")
set(CMAKE_RANLIB "${NATIVE_SYSROOT}/bin/arm-linux-gnueabihf-ranlib")

set(CMAKE_MODULE_PATH ${NATIVE_SYSROOT} ${TARGET_SYSROOT})

